shop.jCarouse = {
	caro:null,
	cat: 0,
	time_id: 0,
	firstRun:function(){
		var d = Math.floor((Math.random()*10)+1);
		if(d % 2 == 0){
			shop.jCarouse.run();
		}
	},
	run:function(){
		var curPage = jQuery.jcarousel.intval(jQuery('.v6PageActived').attr('cat')), page = 1, type = 'prev';
		if(curPage == 1){
			page = 2;
			type = 'next';
		}
		if(curPage != page){
			shop.jCarouse.processClick(type);
			shop.jCarouse.processPage(page);
			return true;
		}
		return false;
	},
	auto:function(){
		var second = 20;
		shop.jCarouse.time_id = setTimeout(function(){
			if(shop.jCarouse.run()){
				shop.jCarouse.auto();
			}
		}, second*1000);
	},
	fixWidth:function(){
		var w = jQuery(document).width(), p = "-45px";
		if(w > 1024){
			jQuery('.v7Bgnew').css({width:"251px",right:"-23px"});
			jQuery('.v6NextCatePage').css({right:p});
			jQuery('.v6PreCatePage').css({left:p});
		}
	},
	processClick:function(type){
		if(type == 'next'){
			shop.jCarouse.caro.next();
			jQuery('#v6PreCatePage'+shop.jCarouse.cat).show();  //prev show
			jQuery('#v6NextCatePage'+shop.jCarouse.cat).hide(); //next hide
		}else{
			shop.jCarouse.caro.prev();
			jQuery('#v6PreCatePage'+shop.jCarouse.cat).hide();  //prev hide
			jQuery('#v6NextCatePage'+shop.jCarouse.cat).show(); //next show
		}
	},
	processPage:function(idx){
		jQuery('.v6PageActived').removeClass('v6PageActived');
		jQuery('.v6Page'+idx).addClass('v6PageActived');
	},
	mycarousel_initCallback : function(carousel, cat) {
		shop.jCarouse.caro = carousel;
		shop.jCarouse.cat = cat;
		jQuery('#jCarouselControl'+cat+' a').bind('click', function() {
			var page = jQuery.jcarousel.intval(jQuery(this).attr('cat')),
			curPage = jQuery.jcarousel.intval(jQuery('.v6PageActived').attr('cat')),type='';
			if(page != curPage){
				type = (page == 2) ? 'next' : 'prev';
				shop.jCarouse.processClick(type);
				shop.jCarouse.processPage(page);
			}
			return false;
		});
		jQuery('#v6NextCatePage'+cat).bind('click', function() {
			shop.jCarouse.processClick('next');
			shop.jCarouse.processPage(2);
			return false;
		});
		jQuery('#v6PreCatePage'+cat).bind('click', function() {
			shop.jCarouse.processClick('prev');
			shop.jCarouse.processPage(1);
			return false;
		});
	},
	init:function(cat){
		jQuery("#jCarouselNew"+cat).jcarousel({
			initCallback: function(a, state){shop.jCarouse.mycarousel_initCallback(a, cat)},
			scroll: 4,
			wrap: 'circular',
			buttonNextHTML: null,
			buttonPrevHTML: null,
			itemFallbackDimension:300
		});
		shop.jCarouse.firstRun();
		shop.jCarouse.auto();
	}
};
jQuery(document).ready(function(){
	jQuery(".v6hover").hover(
		function () {
			var id = jQuery(this).attr('lang');
			jQuery("#itemHotMoreDetail"+id).fadeIn(200);
		},
		function () {
			var id = jQuery(this).attr('lang');
			jQuery("#itemHotMoreDetail"+id).fadeOut(200);
		}
	);
	jQuery(".v6ItemImg").hover(
		function () {
			var id = jQuery(this).attr('langhot');
			jQuery("#itemHotMoreDetails"+id).fadeIn(200);
		},
		function () {
			var id = jQuery(this).attr('langhot');
			jQuery("#itemHotMoreDetails"+id).fadeOut(200);
		}
	);
});